//引入用户数据库模块
const ExercisesModel_DB = require("../models/ExercisesModel_DB")
//引入发送前端工具
const Response = require("../utils/ResponseEntity")

class ExercisesController {
    //获取所有类型
    async findAll(req, res, next) {
        try {
            const data = await ExercisesModel_DB.find()
            if (data.length) res.send(Response.success({ msg: "查询成功", data }))
            else res.send(Response.error({ msg: "查询失败" }))
        } catch (error) {
            console.log(error);
            res.send(ResponseEntity.error({ msg: "服务器错误" }))
        }
    }

    //根据试卷id查找
/*     async findByTestId(req, res, next) {
        try {
            const { id } = req.query
            const data = await ExercisesModel_DB.find
            res.send(Response.success({ msg: "ok" }))
        } catch (error) {
            console.log(error);
            res.send(ResponseEntity.error({ msg: "服务器错误" }))
        }
    } */
}

const exercises = new ExercisesController()
module.exports = exercises